<template>
  <van-nav-bar title="烹饪步骤" left-text="返回" left-arrow @click-left="() => { router.back() }" />
  <foodStep v-if="flag" :msg="data[0]"></foodStep>
</template>

<script setup>
import foodStep from '@/components/foodStep.vue'
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import router from '@/router/index.js';
import { getCookById } from '@/api/index.js'
import { isLogin } from '@/utils/isLogin.js'


// 当前路由信息
const route = useRoute()

const flag = ref(false)
const data = ref({})

onMounted(async () => {
  if (isLogin()) {
    const res = await getCookById(route.query.id)
    data.value = res.data;
    flag.value = true;
    console.log(data.value);
  } else {
    router.push('/login')
  }

})

</script>

<style lang="less" scoped></style>